<?php

namespace App\Http\Controllers;

use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;

class BaseController extends Controller
{
    public function success( $data=[] , $code=200,String $msg='OK')
    {
        $res=[
            'code'=>$code,
            'msg'=>$msg,
            'data'=>$data,
        ];

        return response()->json($res);
    }

    public function error( $msg='error' , $code=400 )
    {
        abort($code,$msg);
    }

    public function apiError($msg='error',$code=400)
    {
        $res=[
            'code'=>$code,
            'msg'=>$msg,
        ];

        return response()->json($res,$code);
    }
}
